package com.zlp.mall.portal.config;

import com.zlp.mall.portal.component.trade.alipay.TradePayProp;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;

/**
 * 权限验证拦截器
 */
@Configuration
public class GlobalWebAppConfigurer implements WebMvcConfigurer {

    @Resource
    private TradePayProp tradePayProp;

//    /**
//     * 该拦截器主要是为了权限验证
//     * @param registry
//     */
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(authInterceptor()).addPathPatterns("/**");
//    }
//
//    @Bean
//    @ConfigurationProperties(prefix = "secure.ignored")
//    public AuthInterceptor authInterceptor(){
//        return new AuthInterceptor();
//    }




    /**
     * 将物理文件夹中的支付二维码映射为静态资源路径
     * @param registry
     * @date: 2021/10/25 10:58
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(tradePayProp.getHttpBasePath()+"/**")
                .addResourceLocations("file:"+tradePayProp.getStorePath()+"/");
    }
}
